/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package smary.ejb.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *Abbildung der Productbacklogs in einer Entität nach den Anforderungen von Scrum.
 * @author Alex
 * 
 */
@Entity
@Table(name = "PRODUCTBACKLOG")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Productbacklog.findAll", query = "SELECT p FROM Productbacklog p"),
    @NamedQuery(name = "Productbacklog.findByProductbacklogid", query = "SELECT p FROM Productbacklog p WHERE p.productbacklogid = :productbacklogid"),
    @NamedQuery(name = "Productbacklog.findByBacklogbezeichnung", query = "SELECT p FROM Productbacklog p WHERE p.backlogbezeichnung = :backlogbezeichnung"),
    @NamedQuery(name = "Productbacklog.findByBacklogbeschreibung", query = "SELECT p FROM Productbacklog p WHERE p.backlogbeschreibung = :backlogbeschreibung"),
    @NamedQuery(name = "Productbacklog.findByBacklogbeginn", query = "SELECT p FROM Productbacklog p WHERE p.backlogbeginn = :backlogbeginn"),
    @NamedQuery(name = "Productbacklog.findByBacklogende", query = "SELECT p FROM Productbacklog p WHERE p.backlogende = :backlogende")})
public class Productbacklog implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "PRODUCTBACKLOGID")
    @GeneratedValue(strategy= GenerationType.AUTO)
    private Integer productbacklogid;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2048)
    @Column(name = "BACKLOGBEZEICHNUNG")
    private String backlogbezeichnung;
    @Size(min = 1, max = 32700)
    @Column(name = "BACKLOGBESCHREIBUNG")
    private String backlogbeschreibung;
    @Basic(optional = false)
    @NotNull
    @Column(name = "BACKLOGBEGINN")
    @Temporal(TemporalType.DATE)
    private Date backlogbeginn;
    @Column(name = "BACKLOGENDE")
    @Temporal(TemporalType.DATE)
    private Date backlogende;

    @ManyToOne
    @JoinColumn(name="SCRUMPROJEKT",
            referencedColumnName="ScrumProjektID")
    protected Scrumprojekt scrumprojekt;
    
    @OneToMany(mappedBy="productbacklog")
    protected Set<Userstory> userStories;

    public Scrumprojekt getScrumprojekt() {
        return scrumprojekt;
    }

    public void setScrumprojekt(Scrumprojekt scrumprojekt) {
        this.scrumprojekt = scrumprojekt;
    }

    public Set<Userstory> getUserStories() {
        return userStories;
    }

    public void setUserStories(Set<Userstory> userStories) {
        this.userStories = userStories;
    }
    
    public Productbacklog() {
    }

    public Productbacklog(Integer productbacklogid) {
        this.productbacklogid = productbacklogid;
    }

    public Productbacklog(Integer productbacklogid, String backlogbezeichnung, Date backlogbeginn) {
        this.productbacklogid = productbacklogid;
        this.backlogbezeichnung = backlogbezeichnung;
        this.backlogbeginn = backlogbeginn;
    }

    public Integer getProductbacklogid() {
        return productbacklogid;
    }

    public void setProductbacklogid(Integer productbacklogid) {
        this.productbacklogid = productbacklogid;
    }

    public String getBacklogbezeichnung() {
        return backlogbezeichnung;
    }

    public void setBacklogbezeichnung(String backlogbezeichnung) {
        this.backlogbezeichnung = backlogbezeichnung;
    }

    public String getBacklogbeschreibung() {
        return backlogbeschreibung;
    }

    public void setBacklogbeschreibung(String backlogbeschreibung) {
        this.backlogbeschreibung = backlogbeschreibung;
    }

    public Date getBacklogbeginn() {
        return backlogbeginn;
    }

    public void setBacklogbeginn(Date backlogbeginn) {
        this.backlogbeginn = backlogbeginn;
    }

    public Date getBacklogende() {
        return backlogende;
    }

    public void setBacklogende(Date backlogende) {
        this.backlogende = backlogende;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (productbacklogid != null ? productbacklogid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Productbacklog)) {
            return false;
        }
        Productbacklog other = (Productbacklog) object;
        if ((this.productbacklogid == null && other.productbacklogid != null) || (this.productbacklogid != null && !this.productbacklogid.equals(other.productbacklogid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getProductbacklogid() + " " + getBacklogbezeichnung();
    }
    
}
